#include "station.h"
#include <string>
#include <QDebug>

//创建车站类数组，用于存放车站
Station stationArray[totalStationNumber];

Station::Station(QObject *parent)
    : QObject{parent}
{
    //创建线路组合数组
    int Line01[3]={1,0,0};
    int Line02[3]={2,0,0};
    int Line03[3]={3,0,0};
    int Line04[3]={4,0,0};
    int Line05[3]={5,0,0};
    int Line06[3]={6,0,0};
    int Line08[3]={8,0,0};
    int Line09[3]={9,0,0};
    int Line10[3]={10,0,0};
    int Line11[3]={11,0,0};
    int Line0102[3]={1,2,0};
    int Line0103[3]={1,3,0};
    int Line0105[3]={1,5,0};
    int Line0106[3]={1,6,0};
    int Line0110[3]={1,10,0};
    int Line0204[3]={2,4,0};
    int Line0205[3]={2,5,0};
    int Line0206[3]={2,6,0};
    int Line0210[3]={2,10,0};
    int Line0305[3]={3,5,0};
    int Line0306[3]={3,6,0};
    int Line0405[3]={4,5,0};
    int Line0410[3]={4,10,0};
    int Line0506[3]={5,6,0};
    int Line0509[3]={5,9,0};
    int Line0510[3]={5,10,0};
    int Line0608[3]={6,8,0};
    int Line1011[3]={10,11,0};
    int Line020309[3]={2,3,9};

    //录入车站信息
    Station Liuyuan("刘园",Line01);
    Station Ruijingxinyuan("瑞景新苑",Line01);
    Station Jiayuanli("佳园里",Line01);
    Station Benxilu("本溪路",Line01);
    Station Qinjiandao("勤俭道",Line01);
    Station Honghuli("洪湖里",Line01);
    Station Xizhan("西站",Line0106);
    Station Xibeijiao("西北角",Line01);
    Station Xinanjao("西南角",Line0102);
    Station Erweilu("二纬路",Line01);
    Station Haiguangsi("海光寺",Line01);
    Station Anshandao("鞍山道",Line01);
    Station Yingkoudao("营口道",Line0103);
    Station Xiaobailou("小白楼",Line01);
    Station Xiawafang("下瓦房",Line0105);
    Station Nanlou("南楼",Line01);
    Station Tucheng("土城",Line01);
    Station Chentangzhuang("陈塘庄",Line01);
    Station Fuxingmen("复兴门",Line01);
    Station Huashanli("华山里",Line01);
    Station Caijingdaxue("财经大学",Line0110);
    Station Shuanglin("双林",Line01);
    Station Lilou("李楼",Line01);
    //Station Lishuanglubei("梨双路北",Line01);//暂缓开通
    Station Hongnihedong("洪泥河东",Line01);
    Station Gaozhuangzi("高庄子",Line01);
    //Station Shangguozhuang("上郭庄",Line01);//暂缓开通
    Station Guojiahuizhanzhongxin("国家会展中心",Line01);
    Station Guoruilu("国瑞路",Line01);
    Station Donggulu("东沽路",Line01);
    //Station Xianshuigubei("咸水沽北",Line01);//暂缓开通
    //Station Shuangqiaohe("双桥河",Line01);//暂缓开通
    Station Caozhuang("曹庄",Line02);
    Station Bianxing("卞兴",Line02);
    Station Jieyuanxidao("芥园西道",Line02);
    Station Xianyanglu("咸阳路",Line02);
    Station Changhonggongyuan("长虹公园",Line0206);
    Station Guangkaisimalu("广开四马路",Line02);
    Station Gulou("鼓楼",Line02);
    Station Dongnanjiao("东南角",Line0204);
    Station Jianguodao("建国道",Line02);
    Station Tianjinzhan("天津站",Line020309);
    Station Yuanyangguojizhongxin("远洋国际中心",Line02);
    Station Shunchiqiao("顺驰桥",Line02);
    Station Jingjianglu("靖江路",Line0205);
    Station Cuifuxingcun("翠阜新村",Line02);
    Station Yudongcheng("屿东城",Line0210);
    Station Dengzhoulu("登州路",Line02);
    Station Guoshanlu("国山路",Line02);
    Station Konggangjingjiqv("空港经济区",Line02);
    Station Binhaiguojijichang("滨海国际机场",Line02);
    Station Xiaodian("小淀",Line03);
    Station Fengchanhe("丰产河",Line03);
    Station Huabeijituan("华北集团",Line03);
    Station Tianshili("天士力",Line03);
    Station Yixingfu("宜兴埠",Line03);
    Station Zhangxingzhuang("张兴庄",Line0305);
    Station Tiedonglu("铁东路",Line03);
    Station Beizhan("北站",Line0306);
    Station Zhongshanlu("中山路",Line03);
    Station Jinshiqiao("金狮桥",Line03);
    Station Jinwanguangchang("津湾广场",Line03);
    Station Hepinglu03("和平路",Line03);//注意和平路
    Station Xikanglu("西康路",Line03);
    Station Wujiayao("吴家窑",Line03);
    Station Tianta("天塔",Line03);
    Station Zhoudengjinianguan("周邓纪念馆",Line03);
    Station Hongqinanlu("红旗南路",Line0306);
    Station Wangdingdi("王顶堤",Line03);
    Station Huayuan("华苑",Line03);
    Station Daxuecheng("大学城",Line03);
    Station Gaoxingqv("高新区",Line03);
    Station Xuefugongyeqv("学府工业区",Line03);
    Station Yangwuzhuang("杨伍庄",Line03);
    Station Nanzhan("南站",Line03);
    Station Xinxingcun("新兴村",Line04);
    Station Minhangdaxue("民航大学",Line04);
    Station Hangshuanglu("航双路",Line04);
    Station Yuejinbeilu("跃进北路",Line04);
    Station Dengzhounanlu("登州南路",Line04);
    Station Shaliunanlu("沙柳南路",Line0410);
    Station Wandonglu("万东路",Line04);
    Station Taichanglu("泰昌路",Line04);
    Station Chenglindao("成林道",Line0405);
    Station Liuweilu("六纬路",Line04);
    Station Xvzhoudao("徐州道",Line04);
    Station Hepinglu04("和平路",Line04);//注意和平路
    Station Jinjie("金街",Line04);
    Station Beichenkejiyuanbei("北辰科技园北",Line05);
    Station Danhebeidao("丹河北道",Line05);
    Station Beichendao("北辰道",Line05);
    Station Zhiyedaxue("职业大学",Line05);
    Station Huaihedao("淮河道",Line05);
    Station Liaohebeidao("辽河北道",Line05);
    Station Yixingfubei("宜兴埠北",Line05);
    Station Zhichenglu("志成路",Line05);
    Station Siyuanlu("思源路",Line05);
    Station Jianchangdao("建昌道",Line05);
    Station Jinzhonghedajie("金钟河大街",Line0506);
    Station Yueyahe("月牙河",Line05);
    Station Xingfugonyuan("幸福公园",Line05);
    Station Jintanglu("津塘路",Line05);
    Station Zhigu("直沽",Line0509);
    Station Xinanlou("西南楼",Line05);
    Station Wenhuazhongxing("文化中心",Line0506);
    Station Tianjinbinguan("天津宾馆",Line0506);
    Station Zhongliuyiyuan("肿瘤医院",Line0506);
    Station Tiyuzhongxin("体育中心",Line05);
    Station Lingbinlu("凌宾路",Line05);
    Station Changlinglu("昌凌路",Line0510);
    Station Zhongyiyifuyuan("中医一附院",Line05);
    Station Liqizhuangnan("李七庄南",Line05);
    Station Nansunzhuang("南孙庄",Line06);
    Station Nanhezhuang("南何庄",Line06);
    Station Dabizhuang("大毕庄",Line06);
    Station Jinzhongjie("金钟街",Line06);
    Station Xvzhuangzi("徐庄子",Line06);
    Station Minqvanmen("民权门",Line06);
    Station Beininggongyuan("北宁公园",Line06);
    Station Xinkaihe("新开河",Line06);
    Station Waiyuanfuzhong("外院附中",Line06);
    Station Tiantailu("天泰路",Line06);
    //Station Beiyunhe("北运河",Line06);//暂缓开通
    Station Beizhulin("北竹林",Line06);
    Station Fuxinglu("复兴路",Line06);
    Station Renminyiyuan("人民医院",Line06);
    Station Yibindao("宜宾道",Line06);
    Station Anshanxidao("鞍山西道",Line06);
    Station Tiantuo("天拖",Line06);
    Station Yizhongxinyiyuan("一中心医院",Line06);
    Station Yingfengdao("迎风道",Line06);
    Station Nancuiping("南翠屏",Line06);
    Station Shuishanggongyuandonglu("水上公园东路",Line06);
    Station Leyuandao("乐园道",Line06);
    Station Jianshanlu("尖山路",Line06);
    Station Yidaeryuan("医大二院",Line06);
    Station Meijiangdao("梅江道",Line06);
    Station Zuojiangdao("左江道",Line06);
    Station Meijianggongyuan("梅江公园",Line06);
    Station Meijianghuizhanzhongxin("梅江会展中心",Line06);
    Station Jiefangnanlu("解放南路",Line06);
    Station Dongtinglu("洞庭路",Line06);
    Station Meilinlu("梅林路",Line06);
    Station Lushuidao("渌水道",Line0608);
    Station Xianshuiguxi("咸水沽西",Line08);
    Station Hehuinanlu("和慧南路",Line08);
    Station Nankaidaxuejinnanxiaoqv("南开大学津南校区",Line08);
    Station Haihejiaoyuyuanqv("海河教育园区",Line08);
    Station Tianjindaxuebeiyangyuanxiaoqv("天津大学北洋园校区",Line08);
    Station Jinglidao("景荔道",Line08);
    Station Jinghedao("景荷道",Line08);
    Station Shuanggang("双港",Line08);
    Station Dawangzhuang("大王庄",Line09);
    Station Shiyijinglu("十一经路",Line09);
    Station Dongxinglu("东兴路",Line09);
    Station Zhongshanmen("中山门",Line09);
    Station Yihaoqiao("一号桥",Line09);
    Station Erhaoqiao("二号桥",Line09);
    Station Zhangguizhuang("张贵庄",Line09);
    Station Xinli("新立",Line09);
    Station Donglikaifaqv("东丽开发区",Line09);
    Station Xiaodongzhuang("小东庄",Line09);
    Station Junliangcheng("军粮城",Line09);
    Station Gangguangongsi("钢管公司",Line09);
    Station Hujiayuan("胡家园",Line09);
    Station Tanggu("塘沽",Line09);
    Station Taida("泰达",Line09);
    Station Shiminguangchang("市民广场",Line09);
    Station Taihulu("太湖路",Line09);
    Station Huizhanzhongxin("会展中心",Line09);
    Station Donghailu("东海路",Line09);
    Station Laoshandao("崂山道",Line10);
    Station Xiangshandao("香山道",Line10);
    Station Wanshandao("万山道",Line10);
    Station Fangshandao("方山道",Line10);
    Station Jinmaochanyeyuan("金贸产业园",Line10);
    Station Longhandao("龙涵道",Line10);
    Station Huanyudao("环宇道",Line1011);
    Station Liulinlu("柳林路",Line10);
    Station Weishanlu("微山路",Line10);
    Station Magangchang("玛钢厂",Line10);
    Station Chunhailu("春海路",Line10);
    Station Nanzhuqiao("南珠桥",Line10);
    Station Youyinanlu("友谊南路",Line10);
    Station Jiangwanerzhilu("江湾二支路",Line10);
    Station Lijiangdao("丽江道",Line10);
    Station Yaohuanlu("瑶环路",Line10);
    Station Yutai("于台",Line10);
    Station Dongliliujinglu("东丽六经路",Line11);
    Station Donglisanjinglu("东丽三经路",Line11);
    Station Dongliyijinglu("东丽一经路",Line11);
    Station Xunhailu("驯海路",Line11);
    Station Dongliwentizhongxin("东丽文体中心",Line11);
    Station Zhaoyuanlu("招远路",Line11);
    Station Xueliannanlu("雪莲南路",Line11);
    Station Haihedonglu("海河东路",Line11);
    Station Xueyuanbeilu("学苑北路",Line11);
    Station Dongjiangdao("东江道",Line11);

    stationArray[0] = Liuyuan;
    stationArray[1] = Ruijingxinyuan;
    stationArray[2] = Jiayuanli;
    stationArray[3] = Benxilu;
    stationArray[4] = Qinjiandao;
    stationArray[5] = Honghuli;
    stationArray[6] = Xizhan;
    stationArray[7] = Xibeijiao;
    stationArray[8] = Xinanjao;
    stationArray[9] = Erweilu;
    stationArray[10] = Haiguangsi;
    stationArray[11] = Anshandao;
    stationArray[12] = Yingkoudao;
    stationArray[13] = Xiaobailou;
    stationArray[14] = Xiawafang;
    stationArray[15] = Nanlou;
    stationArray[16] = Tucheng;
    stationArray[17] = Chentangzhuang;
    stationArray[18] = Fuxingmen;
    stationArray[19] = Huashanli;
    stationArray[20] = Caijingdaxue;
    stationArray[21] = Shuanglin;
    stationArray[22] = Lilou;
    stationArray[23] = Hongnihedong;
    stationArray[24] = Gaozhuangzi;
    stationArray[25] = Guojiahuizhanzhongxin;
    stationArray[26] = Guoruilu;
    stationArray[27] = Donggulu;
    stationArray[28] = Caozhuang;
    stationArray[29] = Bianxing;
    stationArray[30] = Jieyuanxidao;
    stationArray[31] = Xianyanglu;
    stationArray[32] = Changhonggongyuan;
    stationArray[33] = Guangkaisimalu;
    stationArray[34] = Gulou;
    stationArray[35] = Dongnanjiao;
    stationArray[36] = Jianguodao;
    stationArray[37] = Tianjinzhan;
    stationArray[38] = Yuanyangguojizhongxin;
    stationArray[39] = Shunchiqiao;
    stationArray[40] = Jingjianglu;
    stationArray[41] = Cuifuxingcun;
    stationArray[42] = Yudongcheng;
    stationArray[43] = Dengzhoulu;
    stationArray[44] = Guoshanlu;
    stationArray[45] = Konggangjingjiqv;
    stationArray[46] = Binhaiguojijichang;
    stationArray[47] = Xiaodian;
    stationArray[48] = Fengchanhe;
    stationArray[49] = Huabeijituan;
    stationArray[50] = Tianshili;
    stationArray[51] = Yixingfu;
    stationArray[52] = Zhangxingzhuang;
    stationArray[53] = Tiedonglu;
    stationArray[54] = Beizhan;
    stationArray[55] = Zhongshanlu;
    stationArray[56] = Jinshiqiao;
    stationArray[57] = Jinwanguangchang;
    stationArray[58] = Hepinglu03;//3号线和平路
    stationArray[59] = Xikanglu;
    stationArray[60] = Wujiayao;
    stationArray[61] = Tianta;
    stationArray[62] = Zhoudengjinianguan;
    stationArray[63] = Hongqinanlu;
    stationArray[64] = Wangdingdi;
    stationArray[65] = Huayuan;
    stationArray[66] = Daxuecheng;
    stationArray[67] = Gaoxingqv;
    stationArray[68] = Xuefugongyeqv;
    stationArray[69] = Yangwuzhuang;
    stationArray[70] = Nanzhan;
    stationArray[71] = Xinxingcun;
    stationArray[72] = Minhangdaxue;
    stationArray[73] = Hangshuanglu;
    stationArray[74] = Yuejinbeilu;
    stationArray[75] = Dengzhounanlu;
    stationArray[76] = Shaliunanlu;
    stationArray[77] = Wandonglu;
    stationArray[78] = Taichanglu;
    stationArray[79] = Chenglindao;
    stationArray[80] = Liuweilu;
    stationArray[81] = Xvzhoudao;
    stationArray[82] = Hepinglu04;//4号线和平路
    stationArray[83] = Jinjie;
    stationArray[84] = Beichenkejiyuanbei;
    stationArray[85] = Danhebeidao;
    stationArray[86] = Beichendao;
    stationArray[87] = Zhiyedaxue;
    stationArray[88] = Huaihedao;
    stationArray[89] = Liaohebeidao;
    stationArray[90] = Yixingfubei;
    stationArray[91] = Zhichenglu;
    stationArray[92] = Siyuanlu;
    stationArray[93] = Jianchangdao;
    stationArray[94] = Jinzhonghedajie;
    stationArray[95] = Yueyahe;
    stationArray[96] = Xingfugonyuan;
    stationArray[97] = Jintanglu;
    stationArray[98] = Zhigu;
    stationArray[99] = Xinanlou;
    stationArray[100] = Wenhuazhongxing;
    stationArray[101] = Tianjinbinguan;
    stationArray[102] = Zhongliuyiyuan;
    stationArray[103] = Tiyuzhongxin;
    stationArray[104] = Lingbinlu;
    stationArray[105] = Changlinglu;
    stationArray[106] = Zhongyiyifuyuan;
    stationArray[107] = Liqizhuangnan;
    stationArray[108] = Nansunzhuang;
    stationArray[109] = Nanhezhuang;
    stationArray[110] = Dabizhuang;
    stationArray[111] = Jinzhongjie;
    stationArray[112] = Xvzhuangzi;
    stationArray[113] = Minqvanmen;
    stationArray[114] = Beininggongyuan;
    stationArray[115] = Xinkaihe;
    stationArray[116] = Waiyuanfuzhong;
    stationArray[117] = Tiantailu;
    stationArray[118] = Beizhulin;
    stationArray[119] = Fuxinglu;
    stationArray[120] = Renminyiyuan;
    stationArray[121] = Yibindao;
    stationArray[122] = Anshanxidao;
    stationArray[123] = Tiantuo;
    stationArray[124] = Yizhongxinyiyuan;
    stationArray[125] = Yingfengdao;
    stationArray[126] = Nancuiping;
    stationArray[127] = Shuishanggongyuandonglu;
    stationArray[128] = Leyuandao;
    stationArray[129] = Jianshanlu;
    stationArray[130] = Yidaeryuan;
    stationArray[131] = Meijiangdao;
    stationArray[132] = Zuojiangdao;
    stationArray[133] = Meijianggongyuan;
    stationArray[134] = Meijianghuizhanzhongxin;
    stationArray[135] = Jiefangnanlu;
    stationArray[136] = Dongtinglu;
    stationArray[137] = Meilinlu;
    stationArray[138] = Lushuidao;
    stationArray[139] = Xianshuiguxi;
    stationArray[140] = Hehuinanlu;
    stationArray[141] = Nankaidaxuejinnanxiaoqv;
    stationArray[142] = Haihejiaoyuyuanqv;
    stationArray[143] = Tianjindaxuebeiyangyuanxiaoqv;
    stationArray[144] = Jinglidao;
    stationArray[145] = Jinghedao;
    stationArray[146] = Shuanggang;
    stationArray[147] = Dawangzhuang;
    stationArray[148] = Shiyijinglu;
    stationArray[149] = Dongxinglu;
    stationArray[150] = Zhongshanmen;
    stationArray[151] = Yihaoqiao;
    stationArray[152] = Erhaoqiao;
    stationArray[153] = Zhangguizhuang;
    stationArray[154] = Xinli;
    stationArray[155] = Donglikaifaqv;
    stationArray[156] = Xiaodongzhuang;
    stationArray[157] = Junliangcheng;
    stationArray[158] = Gangguangongsi;
    stationArray[159] = Hujiayuan;
    stationArray[160] = Tanggu;
    stationArray[161] = Taida;
    stationArray[162] = Shiminguangchang;
    stationArray[163] = Taihulu;
    stationArray[164] = Huizhanzhongxin;
    stationArray[165] = Donghailu;
    stationArray[166] = Laoshandao;
    stationArray[167] = Xiangshandao;
    stationArray[168] = Wanshandao;
    stationArray[169] = Fangshandao;
    stationArray[170] = Jinmaochanyeyuan;
    stationArray[171] = Longhandao;
    stationArray[172] = Huanyudao;
    stationArray[173] = Liulinlu;
    stationArray[174] = Weishanlu;
    stationArray[175] = Magangchang;
    stationArray[176] = Chunhailu;
    stationArray[177] = Nanzhuqiao;
    stationArray[178] = Youyinanlu;
    stationArray[179] = Jiangwanerzhilu;
    stationArray[180] = Lijiangdao;
    stationArray[181] = Yaohuanlu;
    stationArray[182] = Yutai;
    stationArray[183] = Dongliliujinglu;
    stationArray[184] = Donglisanjinglu;
    stationArray[185] = Dongliyijinglu;
    stationArray[186] = Xunhailu;
    stationArray[187] = Dongliwentizhongxin;
    stationArray[188] = Zhaoyuanlu;
    stationArray[189] = Xueliannanlu;
    stationArray[190] = Haihedonglu;
    stationArray[191] = Xueyuanbeilu;
    stationArray[192] = Dongjiangdao;

}
Station::Station(std::string name,int m_LineNumber[3]){
    this->m_Name = name;
    this->m_LineNumber[0] = m_LineNumber[0];
    this->m_LineNumber[1] = m_LineNumber[1];
    this->m_LineNumber[2] = m_LineNumber[2];
}

bool stationExist(std::string station1,std::string station2){
    bool exist1 = false;
    bool exist2 = false;
    if(station1 == "和平路"){
        exist1 = true;
    }
    else{
        for(int i=0;i<=192;i++){
            if(station1 == stationArray[i].m_Name){
                exist1= true;
            }
        }
    }
    if(station2=="和平路"){
        exist2=true;
    }
    else{
        for(int i=0;i<=192;i++){
            if(station2 == stationArray[i].m_Name){
                exist2 = true;
            }
        }
    }
    return exist1&&exist2;
}
bool stationIdentical(std::string station1,std::string station2){
    if(station1== station2){
        return true;
    }
    else{
        return false;
    }
}

int findStation(std::string stationName){
    if(stationName != "和平路"){
        for(int i = 0;i <= 192;i++){
            if(stationName == stationArray[i].m_Name){
                return i;//站名不为和平路时，返回编号
            }
        }
    }
    return -1;//根据routeplan.cpp中的设置，此路径永不会执行
}

//使用弗洛伊德(Floyd)算法求任意两站的最短路径
int Distance[193][193];//距离矩阵
int Path[193][193];//路径矩阵

void setDistance01(){
    for(int i = 0;i < 193;i++){
        for(int j = 0;j < 193;j++){
            if(i != j){
                Distance[i][j] = 200;//不同站之间距离设为200（象征着无穷，不能设为INT_MAX，因为INT_MAX+1会溢出）
            }
            else{
                Distance[i][j] = 0;//相同站之间距离设为0
            }
        }
    }
    for(int i=0;i<=26;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;//相邻站距离设为1，注意Distance矩阵为对称矩阵
    }
    for(int i=28;i<=32;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[33][8]=Distance[8][33]=1;
    Distance[8][34]=Distance[34][8]=1;
    for(int i=34;i<=45;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    for(int i=47;i<=55;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[56][37]=Distance[37][56]=1;
    Distance[37][57]=Distance[57][37]=1;
    for(int i=57;i<=57;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[58][12]=Distance[12][58]=1;
    Distance[12][59]=Distance[59][12]=1;
    for(int i=59;i<=69;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    for(int i=71;i<=82;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[83][35]=Distance[35][83]=1;
    for(int i=84;i<=89;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[90][52]=Distance[52][90]=1;
    Distance[52][91]=Distance[91][52]=1;
    for(int i=91;i<=95;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[96][40]=Distance[40][96]=1;
    Distance[40][79]=Distance[79][40]=1;
    Distance[79][97]=Distance[97][79]=1;
    for(int i=97;i<=97;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[98][14]=Distance[14][98]=1;
    Distance[14][99]=Distance[99][14]=1;
    for(int i=99;i<=106;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    for(int i=108;i<=111;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[112][94]=Distance[94][112]=1;
    Distance[94][113]=Distance[113][94]=1;
    for(int i=113;i<=113;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[114][54]=Distance[54][114]=1;
    Distance[54][115]=Distance[115][54]=1;
    for(int i=115;i<=117;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[118][6]=Distance[6][118]=1;
    Distance[6][119]=Distance[119][6]=1;
    for(int i=119;i<=119;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[120][32]=Distance[32][120]=1;
    Distance[32][121]=Distance[121][32]=1;
    for(int i=121;i<=123;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[124][63]=Distance[63][124]=1;
    Distance[63][125]=Distance[125][63]=1;
    for(int i=125;i<=126;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[127][102]=Distance[102][127]=1;
    Distance[100][128]=Distance[128][100]=1;
    for(int i=128;i<=137;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    for(int i=139;i<=145;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[146][138]=Distance[138][146]=1;
    Distance[37][147]=Distance[147][37]=1;
    for(int i=147;i<=147;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[148][98]=Distance[98][148]=1;
    Distance[98][149]=Distance[149][98]=1;
    for(int i=149;i<=164;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[42][166]=Distance[166][42]=1;
    for(int i=166;i<=167;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[168][76]=Distance[76][168]=1;
    Distance[76][169]=Distance[169][76]=1;
    for(int i=169;i<=172;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[173][20]=Distance[20][173]=1;
    Distance[20][174]=Distance[174][20]=1;
    for(int i=174;i<=179;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[180][105]=Distance[105][180]=1;
    Distance[105][181]=Distance[181][105]=1;
    for(int i=181;i<=181;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    for(int i=183;i<=188;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
    Distance[189][172]=Distance[172][189]=1;
    Distance[172][190]=Distance[190][172]=1;
    for(int i=190;i<=191;i++){
        Distance[i][i+1]=Distance[i+1][i]=1;
    }
}
void setDistance02(){
    Distance[58][82]=Distance[82][58]=0;//和平路
    Distance[13][81]=Distance[81][13]=0;//小白楼-徐州道
    Distance[132][178]=Distance[178][132]=0;//左江道-友谊南路
    Distance[151][171]=Distance[171][151]=0;//一号桥-龙涵道
    Distance[19][192]=Distance[192][19]=0;//华山里-东江道
}
void setPath(){
    for(int i = 0;i < 193;i++){
        for(int j = 0;j < 193;j++){
            Path[i][j] = -1;//初始将Path所有元素设为-1，表示无路径
            if(Distance[i][j] != 200){
                Path[i][j] = i;//若i到j距离不为无穷（即200），则更新Path[i][j]
            }
        }
    }
}

void updateDistancePath(){
    for(int k = 0;k < 193;k++){
        for(int i = 0;i < 193;i++){
            for(int j = 0;j < 193;j++){
                if(Distance[i][k] + Distance[k][j] < Distance[i][j]){
                    Distance[i][j] = Distance[i][k] + Distance[k][j];//比较取小并更新
                    Path[i][j] = k;
                }
            }
        }
    }//最外层为中间点k在循环，遍历出以k为中间点的路径并与直达路径作比较，而后更新Distance矩阵
    for(int i = 0;i < 193;i++){
        for(int j = 0;j < 193;j++){
            Path[i][j] = previousPoint(i,j);
        }
    }
}
int previousPoint(int m,int n){
    if(Path[m][n] == m){
        return m;
    }
    else{
        return previousPoint(Path[m][n],n);
    }
    return -1;//永不会执行此路径
}

int whichHepingluDeparture(int destinationStation){
    return Distance[58][destinationStation]<Distance[82][destinationStation]?58:82;
}
int whichHepingluDestination(int departureStation){
    return Distance[departureStation][58]<Distance[departureStation][82]?58:82;
}//其实以上两个函数可以合二为一，因为Distance[i][j]=Distance[j][i]

void fillRouteArray(int m, int n, int *p) {
    if(Path[m][n] != m){
        *p++ = n;
        routeArrayLength++;
        fillRouteArray(m, Path[m][n], p);
        return;
    }
    else{
        *p++ = n;
        routeArrayLength++;
        *p++ = m;
        routeArrayLength++;
        return;
    }
}

int *routeArray = new int[200];
int routeArrayLength = 0;
int *Query(int depatureStation, int destinationStation) {
    routeArrayLength = 0;//每次查询都要重新将设为0
    int *routeArrayEnd = routeArray;
    fillRouteArray(depatureStation, destinationStation, routeArrayEnd);
    return routeArray;//返回翻转后的路径的起始地址
}

int getLength(int m,int n){
    return Distance[m][n];
}
bool viaTianjinbinguan(int *p,int x){
    bool judge = false;
    for(int i = 0;i < x;i++){
        if(p[i] == 101){
            judge = true;
        }
    }
    return judge;
}
bool judgeTransfer(int m,int  n){
    bool judge = false;
    if(getLine(m,n) == -1){
        judge = true;
    }
    return judge;
}
int getLine(int m,int n){
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if((stationArray[m].m_LineNumber[i] == stationArray[n].m_LineNumber[j])&&(stationArray[m].m_LineNumber[i] != 0)){
                return stationArray[m].m_LineNumber[i];
            }
        }
    }
    return -1;
}




